package com.hssy.wululuaplan.common;

import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Getter;

@AllArgsConstructor
@Getter
public class Result<T>{

    @ApiModelProperty("状态码")
    private int code;
    @ApiModelProperty("信息")
    private String msg;
    @ApiModelProperty("数据")
    private T data;

    public static <T>Result<T> success() {
        return new Result<>(1,"请求成功！", null);
    }

    public static <T>Result<T> success(int code, String msg) {
        return new Result<>(code, msg, null);
    }

    public static <T>Result<T> success(T data) {
        return new Result<>(1,"请求成功！", data);
    }

    public static <T>Result<T> error() {
        return new Result<>(-1,"请求失败！", null);
    }

    public static <T>Result<T> error(int code, String msg) {
        return new Result<>(code,msg, null);
    }

}
